package tyk.mapper;

import org.apache.ibatis.annotations.*;
import tyk.pojo.Blog;

import java.util.List;

@Mapper
public interface BlogMapper {

    /*
    * 查询所有文章
    * */
    @Select("select * from t_blog")
    public List<Blog> getAllBlog();


    /*
    * 根据id获得blog
    * */
    @Select("select * from t_blog where id = #{id}")
    public Blog getBlogById(Integer id);

    /*
    * 新增文章
    * */
    @Insert("insert into `t_blog` (`title`,`content`,`create_date`) values(#{title},#{content},#{createDate})")
    int addBlog(Blog blog);


    /*
    * 修改文章
    * */
    @Update("update t_blog set title = #{title},content = #{content} where id = #{id}")
    int doEdit(Blog blog);


    /*
    * 删除文章
    * */
    @Delete("delete from t_blog where id = #{id}")
    int delete(Integer id);
}
